<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/include/page.jsp"%>
<!DOCTYPE HTML>
<html>
	<head>
		<meta charset="utf-8">
		<%@ include file="/common/include/title.jsp" %>
		<title>添加管理员 - 管理员管理 - 用户中心</title>
		<meta name="keywords" content="添加管理员 - 管理员管理 - 用户中心">
		<meta name="description" content="添加管理员 - 管理员管理 - 用户中心">
		<!--请在下方写此页面业务相关的脚本-->
		<script type="text/javascript" src="${rootPath }/common/resouce/static/lib/jquery.validation/1.14.0/jquery.validate.js"></script>
		<script type="text/javascript" src="${rootPath }/common/resouce/static/lib/jquery.validation/1.14.0/validate-methods.js"></script>
		<script type="text/javascript" src="${rootPath }/common/resouce/static/lib/jquery.validation/1.14.0/messages_zh.js"></script>
		<script type="text/javascript">
			$(function() {
				$('.skin-minimal input').iCheck({
					checkboxClass : 'icheckbox-blue',
					radioClass : 'iradio-blue',
					increaseArea : '20%'
				});
				<%--
					表单的Id是为了验证那个表单(form)
				--%>
				$("#form-admin-add")
						.validate(
								{
									rules : {
										adminName : {
											required : true,
											/* 最小长度 */
											minlength : 4,
											/* 最大长度 */
											maxlength : 16
										},
										password : {
											required : true,
										},
										/* 确认密码
										确认密码和密码一样 
										*/
										password2 : {
											required : true,
											/* equal:to和谁相比,#password:id选择器 */
											equalTo : "#password"
										},
										sex : {
											required : true,
										},
										phone : {
											required : true,
											isPhone : true,
										},
										/* 验证文本框: id*/
										email : {
											/* 必填 */
											required : true,
											/* 验证的是email;正则表达式,内部已经写好 */
											email : true,
										},
										adminRole : {
											required : true,
										},
									},
									onkeyup : false,
									focusCleanup : true,
									success : "valid",
									submitHandler : function(form) {
										/* jquery版本的ajax
										当表单融入到h-ui-admin框架中,它期望ajax提交
											ajax提交,返回值一般是json
										*/
										$(form)
										.ajaxSubmit(
												{
													type : 'post',
													success : function(data) {
														console.info("=====" + data)
														/* 因为返回的json中,有info属性 */
														layer.msg(
																data.info,
																{
																	icon : 1,
																	time : 5000,
																},
																function()
																{
																		/* 主线程等待 */
																		/* 弹出的选项卡是否关闭的问题 */
																		/* 如果添加成功的时候关闭或者关闭 */
																		if(data.code == '0')
																		{
																			var index = parent.layer
																					.getFrameIndex(window.name);
																			parent.$('.btn-refresh').click();
																			parent.layer.close(index);
																		}
																}
																);
													},
													error : function(
															XmlHttpRequest,
															textStatus,
															errorThrown) {
														layer
																.msg(
																		'error!',
																		{
																			icon : 1,
																			time : 1000
																		});
													},
													/* 期望ajax的返回值,是json,
													让jquery当成json处理*/
													dataType:"json"
												});
								
								/* 关闭当前选项卡弹出的框框
									当添加成功的时候关闭,
									添加失败不要关闭或者关闭
								*/
								/* var index = parent.layer
										.getFrameIndex(window.name);
								parent.$('.btn-refresh').click();
								parent.layer.close(index); */
							}
						});
		});
		</script>
		<!--/请在上方写此页面业务相关的脚本-->
	</head>
	<body>
		<article class="page-container">
			${requestScope.info }
			<form class="form form-horizontal" id="form-admin-add"  
				action="${rootPath }/back/AdminsBackServlet?method=adminsInsertSubmit" method="post"
				enctype="multipart/form-data">
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-3">角色：</label>
					<div class="formControls col-xs-8 col-sm-9">
						<span class="select-box" style="width: 150px;"> 
							<select class="select" name="roleId" size="1">
									<c:forEach items="${requestScope.roleList }" var="role" varStatus="stat">
										<option value="${role.id }">${role.name }</option>
									</c:forEach>
							</select>
						</span>
					</div>
				</div>
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-3">
						<span class="c-red">*</span>邮箱：
					</label>
					<div class="formControls col-xs-8 col-sm-9">
						<input type="text" class="input-text" placeholder="@" name="email" id="email"
						value="${requestScope.admins.email }">
					</div>
				</div>
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-3">
						<span class="c-red">*</span>密码：
					</label>
					<div class="formControls col-xs-8 col-sm-9">
						<input type="password" class="input-text" autocomplete="off"
							value="" placeholder="密码" id="password" name="password">
					</div>
				</div>
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-3">
						<span class="c-red">*</span>确认密码：
					</label>
					<div class="formControls col-xs-8 col-sm-9">
						<input type="password" class="input-text" autocomplete="off"
							placeholder="确认新密码" id="confirmPass" name="password2">
					</div>
				</div>
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-3">
						<span class="c-red">*</span>真实姓名：
					</label>
					<div class="formControls col-xs-8 col-sm-9">
						<input type="text" class="input-text" value="${requestScope.admins.trueName }" placeholder="" id="trueName" name="trueName">
					</div>
				</div>
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-3">
						<span class="c-red">*</span>性别：
					</label>
					<div class="formControls col-xs-8 col-sm-9 skin-minimal">
						<div class="radio-box">
							<lable for="sex0">
								<input name="sex" type="radio" id="sex0"  value="0">
								未知 
							</lable>
						</div>
						<div class="radio-box">
							<lable for="sex1">
								<input name="sex" type="radio" id="sex1" value="1">
								男 
							</lable>
						</div>
						<div class="radio-box">
							<lable for="sex2">
								<input name="sex" type="radio" id="sex2" value="2">
								女 
							</lable>
						</div>
					</div>
				</div>
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-3">
						<span class="c-red">*</span>手机：
					</label>
					<div class="formControls col-xs-8 col-sm-9">
						<input type="text" class="input-text" value="${requestScope.admins.phone }" placeholder=""
							id="phone" name="phone">
					</div>
				</div>
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-3">
						<span class="c-red">*</span>QQ：
					</label>
					<div class="formControls col-xs-8 col-sm-9">
						<input type="text" class="input-text" value="${requestScope.admins.qq }" placeholder=""
							id="qq" name="qq">
					</div>
				</div>
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-3">
						<span class="c-red">*</span>头像：
					</label>
					<div class="formControls col-xs-8 col-sm-9">
						<input type="file" class="input-text"  placeholder="请上传头像"
							 name="file">
					</div>
				</div> 
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-3">
						<span class="c-red">*</span>状态：</label>
					<div class="formControls col-xs-8 col-sm-9 skin-minimal">
						<div class="radio-box">
							<label for="status0">
								<input name="status" type="radio" id="status0" value="0"
								 ${requestScope.admins.status == '0' ? 'checked' : '' }>
								禁用
							</label>
						</div>
						<div class="radio-box">
							<label for="status1">
								<input name="status" type="radio" id="status1" value="1"  
								${requestScope.admins.status == '1' || requestScope.admins.status == null ? 'checked' : '' }>
								启用
							</label>
						</div>
					</div>
				</div>
				<!-- <div class="row cl">
					<label class="form-label col-xs-4 col-sm-3">备注：</label>
					<div class="formControls col-xs-8 col-sm-9">
						<textarea name="" cols="" rows="" class="textarea"
							placeholder="说点什么...100个字符以内" dragonfly="true"
							onKeyUp="$.Huitextarealength(this,100)"></textarea>
						<p class="textarea-numberbar">
							<em class="textarea-length">0</em>/100
						</p>
					</div>
				</div> -->
				<div class="row cl">
					<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
						<input class="btn btn-primary radius" type="submit"
							value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
					</div>
				</div>
			</form>
		</article>
	</body>
</html>